﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
  <head>
    <meta charset="UTF-8" />
    <link rel="stylesheet" href="../js/easyui/1.3.2/themes/default/easyui.css">
    <link rel="stylesheet" href="../js/easyui/1.3.2/themes/icon.css">
    <script src="../js/easyui/1.3.2/jquery-1.8.0.min.js"></script>
    <script src="../js/easyui/1.3.2/jquery.easyui.min.js"></script>
    <title></title>
    <script>
      var parentWin = window.parent;

      function onJQueryReverseStringClick()
      {
        var valueField = document.getElementById('valueField_jq');
        // use GET
        $.ajax({
          type:"GET",
          url:"http://"+parentWin.connectionInfo.host+":"+parentWin.connectionInfo.port+"/datasnap/rest/TServerMethods1/ReverseString/" + valueField.value,
          async:"true",
          dataType:"json",
          success:function(jsonResult){
            valueField.value = jsonResult.result;
            console.log("GET fetch value : " + jsonResult.result);
          }
        });
        // use POST
        $.ajax({
          type:"POST",
          url:'http://'+parentWin.connectionInfo.host+':'+parentWin.connectionInfo.port+'/datasnap/rest/TServerMethods1/"ReverseString"/',
          data:JSON.stringify({"_parameters":[valueField.value]}),
          async:"true",
          dataType:"json",
          success:function(jsonResult){
            valueField.value = jsonResult.result;
            console.log("POST fetch value : " + jsonResult.result);
          }
        });
      }
    </script>
  </head>

  <body>
    <table>
      <tr>
        <td><input id="valueField_jq" class="loginField" type="text" value="A B C" /></td>
        <td>
          <a
            id="btn"
            href="javascript:onJQueryReverseStringClick();"
            class="easyui-linkbutton"
            data-options="iconCls:'icon-search'"
          >
            ReverseString for jQuery
          </a>
        </td>
      </tr>
    </table>
  </body>
</html>

